package com.zhang.util;

import javax.servlet.http.HttpServletRequest;

// 定义 RequestHolder 类，用于存储 request 信息
public class RequestHolder {
    private static final InheritableThreadLocal<HttpServletRequest> requestHolder = new InheritableThreadLocal<>();

    public static void setRequest(HttpServletRequest request) {
        requestHolder.set(request);
    }

    public static HttpServletRequest getRequest() {
        return requestHolder.get();
    }

    public static void clearRequest() {
        System.out.println("清空RequestHolder");
        requestHolder.remove();
    }
}    